fix(membership): reset is_publishing on thrown exceptions in publish_pending_site#421
Conversation
…pending_site Addresses PR #372 CodeRabbit review feedback (issue #412). The rollback that clears the pending site's 'publishing' flag previously only ran when Site::save() returned a WP_Error. If Site::save() or a downstream hook threw a Throwable (e.g. a PHP exception or Error), the pending site remained stuck in 'Creating' state and the cron/manual retry path could not recover. Wrap the Site::save() call in try/catch(\Throwable) so that both WP_Error returns and thrown exceptions reset is_publishing and return a WP_Error to the caller.
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔨 Build Complete - Ready for Testing!📦 Download Build Artifact (Recommended)Download the zip build, upload to WordPress and test:
🌐 Test in WordPress Playground (Very Experimental)Click the link below to instantly test this PR in your browser - no installation needed! Login credentials: |
Summary
Addresses the unactioned CodeRabbit review feedback from PR #372, tracked in issue #412.
Finding (medium severity): The rollback that clears the pending site's
is_publishingflag only ran whenSite::save()returned aWP_Error. IfSite::save()or a downstream hook threw aThrowable(PHP exception orError), the pending site remained stuck in the"Creating"state and the cron/manual retry path could not recover.Fix: Wrap the
Site::save()call intry/catch(\Throwable $e)so that bothWP_Errorreturns and thrown exceptions resetis_publishingand return aWP_Errorto the caller.Changes
inc/models/class-membership.php— wrap$pending_site->save()intry/catch(\Throwable)inpublish_pending_site()(1 file, 15 lines added)Blast radius
1 file changed. Well within the 5-file quality-debt cap.
Closes #412